<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 100px;
        height: 100px;
        border: 1px solid;
      }
      .active {
        background-color: aquamarine;
      }
    </style>
  </head>
  <body>
    <input type="checkbox" name="username" value="abc" checked />

    <div class="box"></div>

    <button class="addBtn">添加样式</button>
    <button class="removeBtn">移除样式</button>
    <button class="toggleBtn">切换</button>
    <script src="jquery/jquery-3.6.1.js"></script>
    <script>
      // console.log($("input[type=checkbox]").val());

      // let input = $("input[type=checkbox]");

      // console.log(input.attr("checked"));
      // console.log(input.prop("checked"));

      $(".addBtn").click(() => {
        $(".box").addClass("active");
      });

      $(".removeBtn").click(() => {
        $(".box").removeClass("active");
      });

      $(".toggleBtn").click(() => {
        $(".box").toggleClass("active");
      });
    </script>
  </body>
</html>
